<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>核销报单管理 - 销售业绩管理系统</title>
<style type="text/css">
<!--
.STYLE1 {	color: #FFFFFF;
	font-weight: bold;
	font-size: 12px;
}
.STYLE6 {font-size: 12px; }
.STYLE7 {font-size: 12px; background-color: #f5f5f5;margin:0;}
body { 
margin:0;
}
-->
</style>
</head>

<body margin=0>

<table width="100%" bgcolor="#FFFFFF"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="28" class="STYLE7">核销报单管理 &gt;核销报单修改</td>
  </tr>
  <tr>
    <td valign="top"><table width="100%" align="center" >
      <tr>
        <td height="25" colspan="2" bordercolor="#000000" bgcolor="#1C94C4"><div align="center" class="STYLE1">核销报单信息修改</div></td>
      </tr>
      <tr>
      	<input id="verid" type="hidden"></input>
        <td width="32%" height="22" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;所属业务员名称：</div>
        </div></td>
        <td width="68%" height="22" bgcolor="#f5f5f5"><span class="STYLE6">
        <input id="ywyid" type="hidden"></input>
          <input id="ywyname" name="textfield" type="text" value="dwliujianqiang1"  disabled="disabled"/>
          </label>
        </span></td>
      </tr>
	  <tr>
        <td height="22" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;美容院名称：</div>
        </div></td>
        <td height="22" bgcolor="#f5f5f5"><span class="STYLE6">
          <select id="mrylist" name="select" onchange="selectShop()" disabled="disabled">
          </select>
          </label>
        </span></td>
      </tr>
       <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;销售套数：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><span class="STYLE6">
        <input id="lastnum" type="hidden"></input>
          <input id="salesnum" name="textfield4" type="text" size="10" onkeyup="changejf()" />
        </span></td>
      </tr>
      <tr>
        <td height="25" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;核销报单积分：</div>
        </div></td>
        <td height="25" bgcolor="#f5f5f5"><span class="STYLE6">
          <input id="hxbdjf" name="textfield4" type="text" size="10" />
        </span></td>
      </tr>
      <tr>
        <td height="22" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;累计核销积分：</div>
        </div></td>
        <td height="22" bgcolor="#f5f5f5"><input id="lastljhxjf" type="hidden" /><input id="ljhxjf" name="textfield2" type="text" value="0" /></td>
      </tr>
      <tr>
        <td height="22" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;地址：</div>
        </div></td>
        <td height="22" bgcolor="#f5f5f5"><input id="address" name="textfield22" type="text" value="北京朝阳区" /></td>
      </tr>
      <tr>
        <td height="22" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;所属城市：</div>
        </div></td>
        <td height="22" bgcolor="#f5f5f5"><select id="cities" name="select"></select></td>
      </tr>
      <tr>
        <td height="22" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;联系人(法人)：</div>
        </div></td>
        <td height="22" bgcolor="#f5f5f5"><input id="lxr" name="textfield2222" type="text" value="万丽" /></td>
      </tr>
      <tr>
        <td height="22" bgcolor="#f5f5f5"><div align="right" class="STYLE6">
          <div align="left">&nbsp;联系电话：</div>
        </div></td>
        <td height="22" bgcolor="#f5f5f5"><span class="STYLE6"><input id="telphone" name="textfield2222" type="text" value="13600000000" />
          
        </span> </td>
      </tr>
      
      <tr>
        <td height="25" colspan="2" bgcolor="#1C94C4"><div align="center" class="STYLE6">
            <form action="" method="post" name="form1" id="form1">
              <label>
              <input type="button" name="Submit" value="修改"  onclick="winalert()"/>
              </label>
            </form>
        </div></td>
      </tr>
    </table></td>
  </tr>
</table>
<script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
	<script language="javascript">
	$.get("../user/fetchcities",{},function(json){
		var opStr = "";
		for(var i = 0,l = json.length ; i < l ; i++)
		{
			opStr += "<option>" + json[i].CityName + "</option>";
		}
		$("#cities").empty().append(opStr);
	});
	
	
		var url = window.location + "";
		var id = url.substring(url.indexOf("?id=") + 4, url.length);
		$.get("../verification/info", {
			id : id
		}, function(json) {
			$("#verid").prop("value", json.ID);
			$("#ywyid").prop("value", json.SalesmanID);
			$("#ywyname").prop("value", json.SalesmanName);
			$("#mrylist").prop("value", json.BeautyShopID);
			$("#hxbdjf").prop("value", json.ThisIntegral);
			$("#ljhxjf").prop("value", json.TotalIntegral);
			$("#address").prop("value", json.BeautyShopAddress);
			$("#cities").prop("value", json.BeautyShopCity);
			$("#telphone").prop("value", json.Telephone);
			$("#salesnum").prop("value", json.SalesNum);
			$("#lxr").prop("value", json.RelationMan);
			
			var opStr = "<option value='" + json.BeautyShopID + "'>" + json.BeautyShopName + "</option>"
			$("#mrylist").empty().append(opStr);

			$.get("../shop/shopjf",{id:json.BeautyShopID},function(data){
				if(data != null){
					$("#hxbdjf").prop("value",data.integral);
					$("#ljhxjf").prop("value",data.TotalIntegral);
					$("#lastljhxjf").prop("value",parseInt(data.TotalIntegral) - parseInt(data.integral));
					$("#lastnum").prop("value",parseInt(data.lastsalesnum) - parseInt(json.SalesNum));
				}else
					{
						$("#hxbdjf").prop("value",0);
						$("#ljhxjf").prop("value",0);
						$("#lastljhxjf").prop("value",0);
						$("#lastnum").prop("value",0);
					}
			});
			/* $.get("../shop/ywyallshop",{id:json.SalesmanID},function(json){
				var opStr = "<option value='0'>请选择</option>";
				for(var i = 0,l = json.length ; i < l ; i++)
				{
					opStr += "<option value='" + json[i].ID + "'>" + json[i].BeautyShopName + "</option>";
				}
				$("#mrylist").empty().append(opStr);
			}); */
		});
		function winalert() {
			$.post("../verification/edit", {
				id:$("#verid").val(),
				ywyid:$("#ywyid").val(),
				ywy:$("#ywyname").val(),
				mryname:$("#mrylist").find("option:selected").text(),
				mryid:$("#mrylist").val(),
				ljhxjf:$("#ljhxjf").val(),
				hxbdjf:$("#hxbdjf").val(),
				address:$("#address").val(),
				cities:$("#cities").val(),
				telphone:$("#telphone").val(),
				salesnum:$("#salesnum").val(),
				lxr:$("#lxr").val()
			}, function(json) {
				if(json)
					{
					alert("更新成功");
					window.returnValue = "1";
					window.close();
					}
			});
		}
		function changejf(){
			$("#hxbdjf").prop("value",0);
			var num = $("#salesnum").val();
			var hxbdjf = $("#hxbdjf").val();
			var ljhxjf = $("#ljhxjf").val();
			var lastljhxjf = $("#lastljhxjf").val();
			var lastnum = $("#lastnum").val();
			if(hxbdjf == null || hxbdjf == "")
				hxbdjf = 0;
			if(ljhxjf == null || ljhxjf == "")
				ljhxjf = 0;
			if(lastnum < 10){
				if((num + lastnum) <= 10)
					num = 0;
				else{
					num = num - 10 + parseInt(lastnum)
				}
			}
			$("#hxbdjf").prop("value",num * 500);
			$("#ljhxjf").prop("value",(parseInt(num * 500) + parseInt(lastljhxjf)));
		}
		function selectShop(){
			var id = $("#mrylist").val();
			$.get("../shop/shopjf",{id:id},function(json){
				if(json != null){
					$("#hxbdjf").prop("value",0);
					$("#ljhxjf").prop("value",json.TotalIntegral);
					$("#lastljhxjf").prop("value",json.TotalIntegral);
					$("#lastnum").prop("value",json.salesnum);
				}else
					{
						$("#hxbdjf").prop("value",0);
						$("#ljhxjf").prop("value",0);
						$("#lastljhxjf").prop("value",0);
						$("#lastnum").prop("value",0);
					}
			});
		}
		function showUsers(){
			var value = showModalDialog('VerificationUsers.html','选择业务员','dialogWidth:500px;dialogHeight:600px; dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes'); 
			var ywy = value.split(",");
			$("#ywyid").prop("value",ywy[0]);
			$("#ywyname").prop("value",ywy[1]);
			
			$.get("../shop/ywyallshop",{id:ywy[0]},function(json){
				var opStr = "<option value='0'>请选择</option>";
				for(var i = 0,l = json.length ; i < l ; i++)
				{
					opStr += "<option value='" + json[i].ID + "'>" + json[i].BeautyShopName + "</option>";
				}
				$("#mrylist").empty().append(opStr);
			});
		}
	</script>
</body>
</html>
